<template>
  <div>
    <treeselect
      v-model="department"
      style="max-width: 180px"
      :options="deptOptions"
      :show-count="true"
      placeholder="请选择部门"
    />
  </div>
</template>
<script>
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { treeselect } from "@/api/system/dept";
export default {
  components: { Treeselect },
  props: ["value", "size"],
  data() {
    return {
      deptOptions: [],
    };
  },
  computed: {
    department: {
      get() {
        return this.value;
      },
      set(v) {
        this.$emit("input", v);
      },
    },
  },
  created() {
    this.getTreeselect();
  },
  methods: {
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then((response) => {
        this.deptOptions = response.data;
      });
    },
  },
};
</script>
